package com.xunmeng.chapter3;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

public class Client {
    public static void main(String[] args) throws IOException {
        SocketChannel sc=SocketChannel.open();
        sc.connect(new InetSocketAddress("localhost",8080));
        int count =0;
        ByteBuffer buffer=ByteBuffer.allocate(1024*1024);
        while (true){// 接收消息
            count+=sc.read(buffer);
            System.out.println(count);
            buffer.clear();
        }
    }
}
